ruby: 
  device_total = @apple_key.devices.count

- content_for :section_title do
  = @apple_key.team&.name || t('.title')

- content_for :title do
  = t('.title')

- content_for :section_rightpanel do
  .btn-group
    = button_link_to '', private_key_admin_apple_key_path(@apple_key), 'download', \
      class: 'btn btn-outline-secondary btn-icon', \
      title: "#{t('.download_private_key')}", \
      data: { bs_toggle: 'tooltip', bs_custom_class: 'default-tooltip' }
    = button_link_to '', admin_apple_key_path(@apple_key), 'trash-alt', \
      class: 'btn btn-outline-secondary btn-icon', title: t('modals.buttons.destroy'), \
      data: { turbo_method: :delete, turbo_confirm: t('modals.destroy_apple_key.body', name: "#{@apple_key.team&.display_name} (#{@apple_key.team&.team_id})"), bs_toggle: :tooltip, bs_custom_class: 'default-tooltip' }

.row
  .col-md-6
    .card.mb-3
      .card-header
        h3.card-title = t('.team_metadata')
      .card-body.p-0
        .d-flex.px-3.py-2.border-bottom
          .fw-bold.flex-fill = t('simple_form.labels.apple_team.display_name')
          .text-end = link_to @apple_key.team.display_name, edit_admin_apple_team_path(@apple_key.team)
        .d-flex.px-3.py-2
          .fw-bold.flex-fill = t('simple_form.labels.apple_team.team_id')
          .text-end = @apple_key.team.team_id
  .col-md-6
    .card.mb-3
      .card-header
        h3.card-title = t('.key_metadata')
      .card-body.p-0
        .d-flex.px-3.py-2.border-bottom
          .fw-bold.flex-fill = t('simple_form.labels.apple_key.issuer_id')
          .text-end = @apple_key.issuer_id
        .d-flex.px-3.py-2
          .fw-bold.flex-fill = t('simple_form.labels.apple_key.key_id')
          .text-end = @apple_key.key_id
  .col-md-12
    .card
      .card-header
        h3.card-title
          = t('.devices', size: device_total)
      - if device_total
        .card-body.p-0
          table.table.table-bottom-borderless
            tr
              th = t('.udid')
              th = t('.udid_name')
              th = t('.udid_platform')
              th = t('.udid_model')
              th = t('.udid_related_apps')
              th = t('.udid_created_at')
            - @apple_key.devices.order(created_at: :desc).each do |device|
              tr
                td = link_to device.udid, edit_udid_path(udid: device.udid, apple_key: @apple_key.id)
                td = device.name
                td = device.platform
                td = device.model
                td = device.channels.count
                td
                  span title="#{l(device.created_at, format: :nice)}" data-bs-toggle="tooltip" data-bs-custom-class="default-tooltip" data-bs-placement="right"
                    = time_ago_in_words(device.created_at)
      .card-footer
        .float-end
          = button_to t('.sync_now'), sync_devices_admin_apple_key_path(@apple_key), method: :put, class: 'btn btn-success btn-sm'

        - if @apple_key.last_synced_at.present?
          span title="#{l(@apple_key.last_synced_at, format: :nice)}" data-bs-toggle="tooltip" data-bs-custom-class="default-tooltip" data-bs-placement="right"
            = t('.last_synced_at', time: time_ago_in_words(@apple_key.last_synced_at))
        - else
          = t('.never_sync')
